<ui:composition
		xmlns="http://www.w3.org/1999/xhtml"
		xmlns:h="http://java.sun.com/jsf/html"
		xmlns:f="http://java.sun.com/jsf/core"
		xmlns:a4j="http://richfaces.org/a4j"
		xmlns:rich="http://richfaces.org/rich"
		xmlns:ui="http://java.sun.com/jsf/facelets"
		xmlns:itdep="http://itdep.bsuir.by/jsf" xmlns:c="http://java.sun.com/jstl/core"
		>

<h:panelGrid>
<h:panelGrid id="filterMarkPanel">
	<a4j:form>
		<h:outputText value="#{planBundle.semester}"/>
		<h:selectOneListbox value="#{studentMarkBean.filter.term}" id="fTerm"
							style="width:100px" size="1" valueChangeListener="#{studentMarkBean.termChanged}">
			<f:selectItem itemValue=""/>
			<f:selectItem itemValue="1"/>
			<f:selectItem itemValue="2"/>
			<f:selectItem itemValue="3"/>
			<f:selectItem itemValue="4"/>
			<f:selectItem itemValue="5"/>
			<f:selectItem itemValue="6"/>
			<f:selectItem itemValue="7"/>
			<f:selectItem itemValue="8"/>
			<f:selectItem itemValue="9"/>
			<f:selectItem itemValue="10"/>
			<f:selectItem itemValue="11"/>
			<f:selectItem itemValue="12"/>

			<a4j:support event="onchange" action="#{studentMarkBean.changeSessionPeriod}"
						 reRender="studentMarksTable,filterMarkPanel,avMark" ajaxSingle="true"/>
		</h:selectOneListbox>
		<h:selectOneListbox value="#{studentMarkBean.show}" id="fShow"
							style="width:100px" size="1">
			<f:selectItem itemValue="All"/>
			<f:selectItem itemValue="Final"/>
			<a4j:support event="onchange" reRender="studentMarksTable" ajaxSingle="true"/>
		</h:selectOneListbox>
	</a4j:form>
	<a4j:form>
		<h:panelGrid id="sessionPeriod" columns="4">
			<h:outputText value="#{planBundle.session}"/>
			<h:outputText
					value="#{studentMarkBean.currentSession.beginDate}"/>-
			<h:outputText
					value="#{studentMarkBean.currentSession.finishDate}"/>
			<h:outputText value="#{planBundle.extendedtill}"/>
			<h:outputText
					value="#{studentMarkBean.lastExtendedSession}" id="extendedSessionId"/>

		</h:panelGrid>
	</a4j:form>
</h:panelGrid>
<h:panelGrid id="extendSessionPanel">
	<a4j:form>
		<a4j:commandLink value="#{planBundle.extendSession}"
						 action="#{studentMarkBean.addExtendSession}" reRender="extendSessionPanel"
						 rendered="#{!studentMarkBean.showExtendSession}"
						 immediate="true"/>

	</a4j:form>
	<a4j:form>

		<h:panelGrid columns="4" rendered="#{studentMarkBean.showExtendSession}">
			<h:outputText value="Directive N"/>
			<h:inputText value="#{studentMarkBean.directive.directiveNumber}"/>
			<h:outputText value="Directive type"/>
			<itdep:entitySelectMenu value="#{studentMarkBean.directive.directiveType}"
									entityType="directive-type"
									format="{i18n.description}"
									required="true" style="width:150px"/>
			<h:outputText value="Reason of extension"/>
			<itdep:entitySelectMenu value="#{studentMarkBean.event.eventReason}"
									entityType="event-reason"
									format="{i18n.description}"
									required="true" style="width:150px"/>
			<h:outputText value="Extend till:"/>
			<rich:calendar value="#{studentMarkBean.dateExtend}" id="dateExtend" inputSize="14"/>
			<a4j:commandButton value="#{commonBundle.save}" action="#{studentMarkBean.saveExtendedSession}"
							   reRender="extendSessionPanel,extendedSessionId"/>
			<a4j:commandButton value="#{commonBundle.cancel}" action="#{studentMarkBean.cancelExtendedSession}"
							   reRender="extendSessionPanel" immediate="true"/>

		</h:panelGrid>
	</a4j:form>
</h:panelGrid>
<ui:decorate template="/facelets/template/scrollableTableTemplate.xhtml">
	<ui:param name="showAddLink" value="true"/>
	<ui:param name="actionBean" value="#{studentMarkBean}"/>
	<ui:param name="idPrefix" value="studentMarks"/>

	<ui:define name="editPanelContext">
		<h:panelGrid columns="2">
			<h:panelGrid columns="2" rendered="#{!studentMarkBean.sheetCreate}">
				<h:outputText value="#{studentBundle.numberSheet}"/>
				<itdep:entitySelectMenu value="#{studentMarkBean.record.markSheet}"
										entityType="mark-sheet"
										format="{numberSheet}" filter="#{markSheetBean.filter}" anyValue="true"
										required="true" style="width:150px">
					<a4j:support event="onchange" reRender="dateP" ajaxSingle="true"/>
				</itdep:entitySelectMenu>
				<h:outputText value="#{studentBundle.passDate}"/>

				<rich:calendar value="#{studentMarkBean.record.markSheet.datePass}" id="dateP" inputSize="14"/>

				<h:outputText value="#{studentBundle.mark}"/>

				<itdep:entitySelectMenu value="#{studentMarkBean.record.mark}"
										entityType="mark"
										format="{i18n.description}"
										required="true" style="width:150px"/>
				<itdep:errorMessage for="mark"/>
			</h:panelGrid>
			<h:panelGrid columns="2" rendered="#{studentMarkBean.sheetCreate}">


				<h:outputText value="#{studentBundle.finishDate}"/>

				<rich:calendar value="#{studentMarkBean.record.markSheet.dateFinish}" inputSize="14"/>
				<h:outputText value="#{personBundle.employee}"/>
				<itdep:entitySelectMenu value="#{markSheetBean.record.employee}"
										entityType="employee" filter="#{employeeBean.filter}"
										format="{firstName} {lastName}"
										required="true" style="width:150px">
					<a4j:support event="onchange" reRender="markSheetPanel" ajaxSingle="true"/>
				</itdep:entitySelectMenu>
			</h:panelGrid>
		</h:panelGrid>
	</ui:define>
	<ui:define name="tableContext">
		<h:column>
			<f:facet name="header">
				<h:outputText value="#{planBundle.subject}"/>
			</f:facet>
			<itdep:entityOutput
					value="#{record.markSheet.formOfControlSemester.semesterPlan.contentPlan.subject}"
					format="{i18n.fullName}"
					locale="#{subjectDicBean.translationBean.locale}"/>
		</h:column>
		<h:column>
			<f:facet name="header">
				<h:outputText value="#{planBundle.formOfControl}"/>
			</f:facet>
			<itdep:entityOutput
					value="#{record.markSheet.formOfControlSemester.formOfControl}"
					format="{i18n.fullName}"
					locale="#{formOfControlDicBean.translationBean.locale}"/>

		</h:column>
		<h:column>
			<f:facet name="header">
				<h:outputText value="#{studentBundle.mark}"/>
			</f:facet>
			<itdep:entityOutput
					value="#{record.mark}"
					format="{i18n.description}"
					locale="#{markDicBean.translationBean.locale}"/>

		</h:column>
		<h:column>
			<f:facet name="header">
				<h:outputText value="#{studentBundle.passDate}"/>
			</f:facet>
			<h:outputText
					value="#{record.markSheet.datePass}">
				<f:convertDateTime pattern="dd.MM.yyyy" timeZone="EET"/>
			</h:outputText>

		</h:column>
		<h:column>
			<f:facet name="header">
				<h:outputText value="#{studentBundle.numberSheet}"/>
			</f:facet>
			<h:outputText
					value="#{record.markSheet.numberSheet}"/>
		</h:column>
		<rich:column width="21%">
			<f:facet name="header"><rich:spacer/></f:facet>
			<a4j:commandLink value="retake"
							 action="#{studentMarkBean.retake}" reRender="#{idPrefix}TablePanel"
							 immediate="true"/>

		</rich:column>
	</ui:define>
</ui:decorate>

<h:outputText value="#{planBundle.averageMark}"/>
<h:outputText value="#{studentMarkBean.averageMarksSemester}" id="avMark"/>
<h:panelGrid>
	<a4j:form>
		<h:outputText value="#{planBundle.individualDisciplines}"/> &#160;
		<rich:dataTable id="oldStudentMarks" value="#{studentMarkBean.oldMarks}" headerClass="dr-table-header"
						onRowMouseOver="this.style.backgroundColor='#f1f1f1';"
						onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}';"
						var="record" width="120px">
			<h:column>
				<f:facet name="header">
					<h:outputText value="#{planBundle.subject}"/>
				</f:facet>
				<itdep:entityOutput
						value="#{record.markSheet.formOfControlSemester.semesterPlan.contentPlan.subject}"
						format="{i18n.fullName}"
						locale="#{subjectDicBean.translationBean.locale}"/>
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="#{planBundle.formOfControl}"/>
				</f:facet>
				<itdep:entityOutput
						value="#{record.markSheet.formOfControlSemester.formOfControl}"
						format="{i18n.fullName}"
						locale="#{formOfControlDicBean.translationBean.locale}"/>

			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="#{studentBundle.mark}"/>
				</f:facet>
				<itdep:entityOutput
						value="#{record.mark}"
						format="{i18n.description}"
						locale="#{markDicBean.translationBean.locale}"/>

			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="#{studentBundle.passDate}"/>
				</f:facet>
				<h:outputText
						value="#{record.markSheet.datePass}"/>

			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="#{studentBundle.numberSheet}"/>
				</f:facet>
				<h:outputText
						value="#{record.markSheet.numberSheet}"/>
			</h:column>
		</rich:dataTable>
	</a4j:form>
</h:panelGrid>

</h:panelGrid>
</ui:composition>
	
